//
//  iVocAppDelegate.m
//  iVoc
//
//  Created by Wallace Wu on 09-3-5.
//  Copyright Sonic Solutions 2009. All rights reserved.
//

#import "iVocAppDelegate.h"
#import "VocListController.h"
#import "VOCMutableWordList.h"
#import "VOCTestListController.h"
#import "VOCMemoryListController.h"

static iVocAppDelegate *_sharedDelegate = nil;

@implementation iVocAppDelegate

@synthesize window;
@synthesize navigationController;
@synthesize tabBarController;

+(id)sharedAppDelegate
{
    return _sharedDelegate;
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {
	
	// Configure and show the window
    VocListController *wordsController = [[[VocListController alloc] initWithNibName:@"VocListController" bundle:nil] autorelease];
    UINavigationController *wordsNavController = [[UINavigationController alloc] initWithRootViewController:wordsController];
    
    VOCTestListController *testController = [[[VOCTestListController alloc] initWithNibName:@"VocListController" bundle:nil] autorelease];
    UINavigationController *testNavController = [[UINavigationController alloc] initWithRootViewController:testController];
    
    VOCMemoryListController *memoryController = [[[VOCMemoryListController alloc] initWithNibName:@"VocListController" bundle:nil] autorelease];
    UINavigationController *memoryNavController = [[UINavigationController alloc] initWithRootViewController:memoryController];
    
    [tabBarController setViewControllers:[NSArray arrayWithObjects:wordsNavController,memoryNavController,testNavController,nil]];
    
	[window addSubview:[tabBarController view]];
	[window makeKeyAndVisible];
    
    _sharedDelegate = self;
}


- (void)applicationWillTerminate:(UIApplication *)application {
	// Save data if appropriate
    [NSKeyedArchiver archiveRootObject:[VOCMutableWordList favoriteList] toFile:VOC_DEFAULT_FAVORITE_LIST];
}

- (void)dealloc {
	[navigationController release];
	[window release];
	[super dealloc];
}

@end
